package ru.evga.inse.server.gwt.user.client.menu;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;


/**
 * The outermost UI of the application.
 */
public class MainMenuView
    extends Composite
{
    interface Binder
        extends UiBinder<Widget, MainMenuView>
    {
    }

    public interface Presenter
    {
        void goToMain();

        void goToRealty();

        void goToForum();

        void goToAdmin();
    }
    private static final Binder BINDER = GWT.create(Binder.class);
    @UiField
    HasClickHandlers m_general;
    @UiField
    HasClickHandlers m_realty;
    @UiField
    HasClickHandlers m_forum;
    @UiField
    HasClickHandlers m_admin;
    Presenter m_presenter;

    public MainMenuView()
    {
        initWidget(BINDER.createAndBindUi(this));
    }

    @UiHandler("m_general")
    void onMain(ClickEvent event)
    {
        m_presenter.goToMain();
    }

    @UiHandler("m_realty")
    void onRealty(ClickEvent event)
    {
        m_presenter.goToRealty();
    }

    @UiHandler("m_forum")
    void onForum(ClickEvent event)
    {
        m_presenter.goToForum();
    }
    
    @UiHandler("m_admin")
    void onAdmin(ClickEvent event)
    {
        m_presenter.goToAdmin();
    }
    
    public void setPresenter(Presenter presenter)
    {
        m_presenter = presenter;
    }
}
